package jnBase.view
{
	import jnBase.Data;
	import jnBase.eventdispatcher.JNEventDispatcher;
	
	import laya.events.Event;
	
	import ui.tools.wap.OneTitleUI;
	
	public class StepControlWAP extends OneTitleUI
	{
		public var value:int;
		private var des:String;
		public var hasSon:Boolean;
		public function StepControlWAP($i:int,$des:String,$hasSon:Boolean)
		{
			super();
			this.mouseThrough=true;
			height=65;
			des=$des;
			value=$i;
			hasSon=$hasSon;
		}
		override public function onAwake():void
		{
			// TODO Auto Generated method stub
			super.onAwake();
			setSkin(hasSon);
			if(value==Data.currStep){
				select=true;
				setSkin(false);
				SceneToolsWAP.getInstance().currStepBtn=this;
				JNEventDispatcher.getInstance().event(JNEventDispatcher.CLICK_ADD_PAGE);
			}
			else{
				select=false;
			}
			if(value==Data.stepList.length-1){
				oneLine.visible=false;
			}
			btn.label=des;
			/*if(des.length>8){
			btn.labelSize=325/(des.length-1);
			}*/
			redo.on(Event.CLICK,this,redoClick);
		}
		private var isredo:Boolean=false;
		private function redoClick():void
		{
			// TODO Auto Generated method stub
			if(isredo) return ;
			isredo=true;
			Laya.timer.once(800,this,function():void{
				isredo=false;
			});
			JNEventDispatcher.getInstance().event(JNEventDispatcher.RE_DO);
		}
		public function set select($b:Boolean):void{
			btn.selected=$b;
			redo.visible=$b;
		}
		public function setSkin($hasSon):void{
			if($hasSon) {
				this.stretchBtn.skin="mobile/btn_tree_arrowWAP+.png";
				if(value==Data.stepList.length-1){
					oneLine.visible=false;
				}
				else oneLine.visible=true;
			}
			else this.stretchBtn.skin="mobile/btn_tree_arrowWAP-.png";
		}
	}
}